SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[SaveCOIAudit]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].SaveCOIAudit
GO

  
/***************************************************************************  
* Name:   SaveCOI  
* Purpose:  Insert/Update a COI  
*  
* PARAMETERS  
* Name     Description       
* -------------    -----------------------------------------------------------  
*	@Id				unique id (0 for new records to be inserted)  
*	@COIId			Id of Conlict Of Interest table.
*	@Action			Action performed.
*	@AdmPersonId    AdmPersonId of the person perfoming the action.
***************************************************************************/  
CREATE PROCEDURE [dbo].SaveCOIAudit (  
  
	@Id    INT,  
	@COIId INT,
	@Action VARCHAR(100),
	@AdmPersonId  INT
) 
  
AS  
  
BEGIN  
	
	IF @Id = 0
	BEGIN
		INSERT INTO COIAudit (COIId,[Action],AdmPersonId)
		VALUES (@COIId,@Action,@AdmPersonId)
		
		IF @@ERROR <> 0 GOTO ERROR_HANDLER  
	    
		SELECT IDENT_CURRENT('COIAudit')  
		
		RETURN
	END
		
	ERROR_HANDLER:  
	IF @@ERROR <> 0   
	BEGIN  
		RAISERROR('Unable to Save COIAudit', 16, 1)  
		RETURN  
	END
END

